package com.atguigu.gulimall.search.thread;


import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class ThreadTest_callable {
    public static void main(String[] args) throws Exception{
        System.out.println("main...........start........");
        FutureTask<Integer> futureTask = new FutureTask<>(new Callable01());
        new Thread(futureTask).start();
//        阻塞等待整个线程执行完成，获取返回结果
        Integer integer = futureTask.get();
        System.out.println("返回结果："+integer);
        System.out.println("main...........end........");
    }
    public static class Callable01 implements Callable<Integer> {

        @Override
        public Integer call() throws Exception {
            System.out.println("当前线程："+Thread.currentThread().getId());
            int i = 10%3 ;
            System.out.println("运行结果："+i);
            return i;
        }
    }
}